more mem for dirhash

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

more mem for dirhash

Ted Unangst-6
UFS dirhash has a limit on how much memory is used to prevent runaway
allocations. I believe the default limit (2MB) is rather conservative.
It was picked to avoid causing trouble back when machines were tiny and
dirhash was new.

For example, a maildir with 100K files takes about 3MB of memory. Because
this is over the current limit, we will fall back to linear search. This has a
detrimental impact on system wide performance.

I picked a new limit of 5MB. This allows for my one very large directory, a
few additional directories, and some spare room. It's also still reasonably
conservative imo.

One can always change the default via sysctl, which is what I've done locally,
but I think increasing the default will reduce surprises in the future. And
for people with only small directories, there's no change. The increased limit
won't be used.


Index: ufs_dirhash.c
===================================================================
RCS file: /cvs/src/sys/ufs/ufs/ufs_dirhash.c,v
retrieving revision 1.40
diff -u -p -r1.40 ufs_dirhash.c
--- ufs_dirhash.c 26 Oct 2017 02:38:54 -0000 1.40
+++ ufs_dirhash.c 20 Feb 2019 21:48:09 -0000
@@ -1057,7 +1057,7 @@ ufsdirhash_init(void)
  rw_init(&ufsdirhash_mtx, "dirhash_list");
  arc4random_buf(&ufsdirhash_key, sizeof(ufsdirhash_key));
  TAILQ_INIT(&ufsdirhash_list);
- ufs_dirhashmaxmem = 2 * 1024 * 1024;
+ ufs_dirhashmaxmem = 5 * 1024 * 1024;
  ufs_mindirhashsize = 5 * DIRBLKSIZ;
 }
 

Reply | Threaded
Open this post in threaded view
|

Re: more mem for dirhash

Todd C. Miller-3
On Wed, 20 Feb 2019 17:00:23 -0500, "Ted Unangst" wrote:

> I picked a new limit of 5MB. This allows for my one very large directory, a
> few additional directories, and some spare room. It's also still reasonably
> conservative imo.

Yes please, this makes a huge difference with my email dirs ;-)

 - todd

Reply | Threaded
Open this post in threaded view
|

Re: more mem for dirhash

Jeremie Courreges-Anglas-2
On Thu, Feb 21 2019, "Todd C. Miller" <[hidden email]> wrote:
> On Wed, 20 Feb 2019 17:00:23 -0500, "Ted Unangst" wrote:
>
>> I picked a new limit of 5MB. This allows for my one very large directory, a
>> few additional directories, and some spare room. It's also still reasonably
>> conservative imo.
>
> Yes please, this makes a huge difference with my email dirs ;-)

Not with mine:

  vfs.ffs.dirhash_maxmem=33554432
  vfs.ffs.dirhash_mem=12155641

I'm fine with the bump to 5MB though.

I may be naive, but shouldn't dirhash memory be accounted with/like
buffer cache memory (freed when other sybsystems need it)?

--
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply | Threaded
Open this post in threaded view
|

Re: more mem for dirhash

Ted Unangst-6
Jeremie Courreges-Anglas wrote:
> I may be naive, but shouldn't dirhash memory be accounted with/like
> buffer cache memory (freed when other sybsystems need it)?

Probably. The limit exists in part because there is no backpressure.

Reply | Threaded
Open this post in threaded view
|

Re: more mem for dirhash

Mark Kettenis
> From: "Ted Unangst" <[hidden email]>
> Date: Thu, 21 Feb 2019 17:25:09 -0500
>
> Jeremie Courreges-Anglas wrote:
> > I may be naive, but shouldn't dirhash memory be accounted with/like
> > buffer cache memory (freed when other sybsystems need it)?
>
> Probably. The limit exists in part because there is no backpressure.

A more generic backpressure mechanism would be welcome I guess.  But
the current way it works for the page daemon and buffer cache is quite
"fragile".