WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
233097
[libpas] Build and enable libpas on 64bit JSCOnly
https://bugs.webkit.org/show_bug.cgi?id=233097
Summary
[libpas] Build and enable libpas on 64bit JSCOnly
Yusuke Suzuki
Reported
2021-11-14 02:47:43 PST
[libpas] build on Linux
Attachments
Patch
(79.29 KB, patch)
2021-11-14 02:47 PST
,
Yusuke Suzuki
no flags
Details
Formatted Diff
Diff
Patch
(107.54 KB, patch)
2021-11-14 05:34 PST
,
Yusuke Suzuki
no flags
Details
Formatted Diff
Diff
Patch
(115.30 KB, patch)
2021-11-14 23:55 PST
,
Yusuke Suzuki
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
Patch
(115.32 KB, patch)
2021-11-15 01:16 PST
,
Yusuke Suzuki
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
Patch
(120.27 KB, patch)
2021-11-15 01:48 PST
,
Yusuke Suzuki
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
Patch
(134.31 KB, patch)
2021-11-15 01:57 PST
,
Yusuke Suzuki
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
Patch
(135.24 KB, patch)
2021-11-15 02:03 PST
,
Yusuke Suzuki
no flags
Details
Formatted Diff
Diff
Patch
(172.32 KB, patch)
2021-11-15 03:11 PST
,
Yusuke Suzuki
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
Patch
(172.83 KB, patch)
2021-11-15 03:15 PST
,
Yusuke Suzuki
no flags
Details
Formatted Diff
Diff
Patch
(173.12 KB, patch)
2021-11-15 03:28 PST
,
Yusuke Suzuki
no flags
Details
Formatted Diff
Diff
Patch
(174.14 KB, patch)
2021-11-15 03:46 PST
,
Yusuke Suzuki
fpizlo
: review+
Details
Formatted Diff
Diff
Show Obsolete
(10)
View All
Add attachment
proposed patch, testcase, etc.
Yusuke Suzuki
Comment 1
2021-11-14 02:47:57 PST
Created
attachment 444174
[details]
Patch
Yusuke Suzuki
Comment 2
2021-11-14 05:34:06 PST
Created
attachment 444176
[details]
Patch
Yusuke Suzuki
Comment 3
2021-11-14 23:55:55 PST
Created
attachment 444213
[details]
Patch
Yusuke Suzuki
Comment 4
2021-11-15 01:16:45 PST
Created
attachment 444220
[details]
Patch
Yusuke Suzuki
Comment 5
2021-11-15 01:48:00 PST
Created
attachment 444225
[details]
Patch
Yusuke Suzuki
Comment 6
2021-11-15 01:57:23 PST
Created
attachment 444226
[details]
Patch
Yusuke Suzuki
Comment 7
2021-11-15 02:03:27 PST
Created
attachment 444228
[details]
Patch
Yusuke Suzuki
Comment 8
2021-11-15 03:11:42 PST
Created
attachment 444231
[details]
Patch
Yusuke Suzuki
Comment 9
2021-11-15 03:15:52 PST
Created
attachment 444232
[details]
Patch
Yusuke Suzuki
Comment 10
2021-11-15 03:28:15 PST
Created
attachment 444234
[details]
Patch
Yusuke Suzuki
Comment 11
2021-11-15 03:46:03 PST
Created
attachment 444236
[details]
Patch
Filip Pizlo
Comment 12
2021-11-15 09:53:21 PST
Comment on
attachment 444236
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=444236&action=review
Wow, this is cool! Have you checked that the fastMalloc and fastFree fast paths look decent on Linux?
> Source/bmalloc/ChangeLog:14 > + 1. C does not handle `const` variables as constants. So libpas's config is not strictly constant > + in the C spec, and GCC actually rejects it. To make it built correctly, we need to build them > + in C++. In this patch, when building libpas via CMake, we build some libpas C files as C++.
Lol haha that's too funny.
> Source/bmalloc/libpas/src/libpas/pas_cartesian_tree.h:63 > + memset(tree->root.payload, 0, PAS_COMPACT_PTR_SIZE); > + memset(tree->minimum.payload, 0, PAS_COMPACT_PTR_SIZE);
I would use pas_zero_memory instead of memset if possible. Even better, I would say: pas_compact_cartesian_tree_node_ptr_store(&tree->root, NULL) and same for minimum.
> Source/bmalloc/libpas/src/libpas/pas_compact_ptr.h:35 > -#define PAS_COMPACT_PTR_INITIALIZER { .payload = {[0 ... PAS_COMPACT_PTR_SIZE - 1] = 0} } > +#define PAS_COMPACT_PTR_INITIALIZER { .payload = { 0 } }
Does this _really_ zero-fill the whole payload array?
> Source/bmalloc/libpas/src/libpas/pas_internal_config.h:145 > +#if PAS_OS(DARWIN) > +#define PAS_MADVISE_SYMMETRIC 0 > +#else > +#define PAS_MADVISE_SYMMETRIC 1 > +#endif
Is it really necessary to do symmetric decommit on Linux? I thought Linux does fine with asymmetric decommit.
> Source/bmalloc/libpas/src/libpas/pas_large_free_inlines.h:66 > + } while (1);
i would say while (true). Even better, I would make this a "for (;;)" loop. That's how libpas says "loop infinitely" everywhere else.
> Source/bmalloc/libpas/src/libpas/pas_monotonic_time.c:77 > +uint64_t pas_get_current_monotonic_time_nanoseconds(void) > +{ > + struct timespec ts; > + clock_gettime(CLOCK_MONOTONIC, &ts); > + return ts.tv_sec * 1.0e9 + ts.tv_nsec; > +}
I am worried that this creates a huge perf problem on Linux. I don't think it's necessary to fix it to land your patch, but eventually, we may want to consider having platforms that don't have approximate_time instead using the scavenger's tick as their time.
> Source/bmalloc/libpas/src/libpas/pas_page_malloc.c:246 > +#elif PAS_OS(FREEBSD) > + PAS_SYSCALL(madvise((void*)base_as_int, end_as_int - base_as_int, MADV_FREE)); > +#else > + PAS_SYSCALL(madvise((void*)base_as_int, end_as_int - base_as_int, MADV_DONTNEED)); > +#if PAS_OS(LINUX) > + PAS_SYSCALL(madvise((void*)base_as_int, end_as_int - base_as_int, MADV_DONTDUMP)); > +#endif > +#endif
Libpas really wants asymmetric decommit. It works so much better with asymmetric. The semantics we want are: please decommit this page whenever you like, unless someone writes to it, in which case cancel decommit. If someone writes to it after you decommit it, then zero-fill and recommit it please.
> Source/bmalloc/libpas/src/libpas/pas_utils.h:373 > +#define PAS_PAIR_LOW(pair) ((pair).low) > +#define PAS_PAIR_HIGH(pair) ((pair).high)
I think this is fine, but I would have made these static inline functions named "pas_pair_low" and "pas_pair_high" unless I absolutely needed to use them in const context. I'm OK with this, though, it's not a big deal, and it does have the benefit that if we ever did use it in const context, it would Just Work.
Yusuke Suzuki
Comment 13
2021-11-15 21:27:05 PST
Comment on
attachment 444236
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=444236&action=review
Thanks! Yeah, the generated code for fastMalloc looks sane.
>> Source/bmalloc/libpas/src/libpas/pas_cartesian_tree.h:63 >> + memset(tree->minimum.payload, 0, PAS_COMPACT_PTR_SIZE); > > I would use pas_zero_memory instead of memset if possible. > > Even better, I would say: pas_compact_cartesian_tree_node_ptr_store(&tree->root, NULL) and same for minimum.
Nice, changed.
>> Source/bmalloc/libpas/src/libpas/pas_compact_ptr.h:35 >> +#define PAS_COMPACT_PTR_INITIALIZER { .payload = { 0 } } > > Does this _really_ zero-fill the whole payload array?
Yes
https://stackoverflow.com/questions/201101/how-to-initialize-all-members-of-an-array-to-the-same-value
>> Source/bmalloc/libpas/src/libpas/pas_internal_config.h:145 >> +#endif > > Is it really necessary to do symmetric decommit on Linux? I thought Linux does fine with asymmetric decommit.
OK, in Linux, we can use MADV_FREE / MADV_DONTNEED. We can make Linux asymmetric too. Changed.
>> Source/bmalloc/libpas/src/libpas/pas_large_free_inlines.h:66 >> + } while (1); > > i would say while (true). Even better, I would make this a "for (;;)" loop. That's how libpas says "loop infinitely" everywhere else.
OK, changed :)
>> Source/bmalloc/libpas/src/libpas/pas_monotonic_time.c:77 >> +} > > I am worried that this creates a huge perf problem on Linux. I don't think it's necessary to fix it to land your patch, but eventually, we may want to consider having platforms that don't have approximate_time instead using the scavenger's tick as their time.
Yup! I've changed it to CLOCK_MONOTONIC_COARSE, which offers the same thing to mach_approximate_time on Linux.
>> Source/bmalloc/libpas/src/libpas/pas_page_malloc.c:246 >> +#endif > > Libpas really wants asymmetric decommit. It works so much better with asymmetric. The semantics we want are: please decommit this page whenever you like, unless someone writes to it, in which case cancel decommit. If someone writes to it after you decommit it, then zero-fill and recommit it please.
Yeah, changed it to use MADV_FREE / MADV_DONTNEED in Linux to make it asymmetric.
>> Source/bmalloc/libpas/src/libpas/pas_utils.h:373 >> +#define PAS_PAIR_HIGH(pair) ((pair).high) > > I think this is fine, but I would have made these static inline functions named "pas_pair_low" and "pas_pair_high" unless I absolutely needed to use them in const context. I'm OK with this, though, it's not a big deal, and it does have the benefit that if we ever did use it in const context, it would Just Work.
OK, changed it to inline function.
Yusuke Suzuki
Comment 14
2021-11-15 23:02:52 PST
Committed
r285853
(
244279@main
): <
https://commits.webkit.org/244279@main
>
Radar WebKit Bug Importer
Comment 15
2021-11-15 23:03:25 PST
<
rdar://problem/85444660
>
Yusuke Suzuki
Comment 16
2021-11-16 12:56:04 PST
Committed
r285880
(
244306@main
): <
https://commits.webkit.org/244306@main
>
Yusuke Suzuki
Comment 17
2021-11-19 00:54:55 PST
Committed
r286051
(
244438@main
): <
https://commits.webkit.org/244438@main
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug