<div dir="ltr"><div dir="ltr"><div dir="ltr"><p class="gmail-ng-star-inserted" style="box-sizing:border-box;font-size:14px;line-height:20px;margin-bottom:18px;font-family:"Google Sans Text","Helvetica Neue",sans-serif;color:rgb(26,28,30)"><span class="gmail-ng-star-inserted" style="box-sizing:border-box">Hi CRaC developers,</span></p><p class="gmail-ng-star-inserted" style="box-sizing:border-box;font-size:14px;line-height:20px;margin-bottom:18px;font-family:"Google Sans Text","Helvetica Neue",sans-serif;color:rgb(26,28,30)"><span style="box-sizing:border-box;display:contents"><span class="gmail-ng-star-inserted" style="box-sizing:border-box">I'm currently exploring the integration of CRaC support into our company's middleware products. I'm also very interested in the underlying implementation details of CRaC and have been doing some research into its mechanics.</span></span></p><p class="gmail-ng-star-inserted" style="box-sizing:border-box;font-size:14px;line-height:20px;margin-bottom:18px;font-family:"Google Sans Text","Helvetica Neue",sans-serif;color:rgb(26,28,30)"><span style="box-sizing:border-box;display:contents"><span class="gmail-ng-star-inserted" style="box-sizing:border-box">As I understand it, CRaC leverages CRIU under the hood for checkpointing and restoring running processes. My research indicates that CRIU itself is capable of handling open file descriptors and established network connections during the checkpoint/restore cycle.</span></span></p><p class="gmail-ng-star-inserted" style="box-sizing:border-box;font-size:14px;line-height:20px;margin-bottom:18px;font-family:"Google Sans Text","Helvetica Neue",sans-serif;color:rgb(26,28,30)"><span style="box-sizing:border-box;display:contents"><span class="gmail-ng-star-inserted" style="box-sizing:border-box">However, the CRaC API requires developers to explicitly manage these resources, typically by closing them in the </span><span class="gmail-inline-code gmail-ng-star-inserted" style="box-sizing:border-box;background-image:none;background-position:0% 0%;background-size:auto;background-repeat:repeat;background-origin:padding-box;background-clip:border-box;border-color:rgb(243,243,246);border-style:solid;border-width:1px;border-radius:3px;font-size:13px;padding:0px 3px;display:inline-block;font-family:"DM Mono",monospace">beforeCheckpoint()</span><span class="gmail-ng-star-inserted" style="box-sizing:border-box"> and re-establishing them in the </span><span class="gmail-inline-code gmail-ng-star-inserted" style="box-sizing:border-box;background-image:none;background-position:0% 0%;background-size:auto;background-repeat:repeat;background-origin:padding-box;background-clip:border-box;border-color:rgb(243,243,246);border-style:solid;border-width:1px;border-radius:3px;font-size:13px;padding:0px 3px;display:inline-block;font-family:"DM Mono",monospace">afterRestore()</span><span class="gmail-ng-star-inserted" style="box-sizing:border-box">.</span></span></p><p class="gmail-ng-star-inserted" style="box-sizing:border-box;font-size:14px;line-height:20px;margin-bottom:18px;font-family:"Google Sans Text","Helvetica Neue",sans-serif;color:rgb(26,28,30)"><span style="box-sizing:border-box;display:contents"><span class="gmail-ng-star-inserted" style="box-sizing:border-box">To understand the rationale behind this design choice, I looked into the initial CRaC prototype, specifically the first PR (<a href="https://github.com/openjdk/crac/pull/1">https://github.com/openjdk/crac/pull/1</a></span><span class="gmail-ng-star-inserted" style="box-sizing:border-box">). It appears that even in this early version, the implementation iterated through all process file descriptors during checkpoint. It ignored certain FDs (like those related to classpath files, </span><span class="gmail-inline-code gmail-ng-star-inserted" style="box-sizing:border-box;background-image:none;background-position:0% 0%;background-size:auto;background-repeat:repeat;background-origin:padding-box;background-clip:border-box;border-color:rgb(243,243,246);border-style:solid;border-width:1px;border-radius:3px;font-size:13px;padding:0px 3px;display:inline-block;font-family:"DM Mono",monospace">/dev/random</span><span class="gmail-ng-star-inserted" style="box-sizing:border-box">, </span><span class="gmail-inline-code gmail-ng-star-inserted" style="box-sizing:border-box;background-image:none;background-position:0% 0%;background-size:auto;background-repeat:repeat;background-origin:padding-box;background-clip:border-box;border-color:rgb(243,243,246);border-style:solid;border-width:1px;border-radius:3px;font-size:13px;padding:0px 3px;display:inline-block;font-family:"DM Mono",monospace">/dev/urandom</span><span class="gmail-ng-star-inserted" style="box-sizing:border-box">, and files marked </span><span class="gmail-inline-code gmail-ng-star-inserted" style="box-sizing:border-box;background-image:none;background-position:0% 0%;background-size:auto;background-repeat:repeat;background-origin:padding-box;background-clip:border-box;border-color:rgb(243,243,246);border-style:solid;border-width:1px;border-radius:3px;font-size:13px;padding:0px 3px;display:inline-block;font-family:"DM Mono",monospace">M_PERSISTENT</span><span class="gmail-ng-star-inserted" style="box-sizing:border-box"> - though I'm unclear on the exact meaning of </span><span class="gmail-inline-code gmail-ng-star-inserted" style="box-sizing:border-box;background-image:none;background-position:0% 0%;background-size:auto;background-repeat:repeat;background-origin:padding-box;background-clip:border-box;border-color:rgb(243,243,246);border-style:solid;border-width:1px;border-radius:3px;font-size:13px;padding:0px 3px;display:inline-block;font-family:"DM Mono",monospace">M_PERSISTENT</span><span class="gmail-ng-star-inserted" style="box-sizing:border-box"> in this context). If any other application-opened files remained, the checkpoint process would fail. This suggests the requirement for manual resource management was present from the outset.</span></span></p><p class="gmail-ng-star-inserted" style="box-sizing:border-box;font-size:14px;line-height:20px;margin-bottom:18px;font-family:"Google Sans Text","Helvetica Neue",sans-serif;color:rgb(26,28,30)"><span style="box-sizing:border-box;display:contents"><span class="gmail-ng-star-inserted" style="box-sizing:border-box">As I'm not deeply familiar with JVM internals, I'm struggling to fully grasp the reasoning. Was this restriction primarily introduced to simplify the initial design and implementation of CRaC within the JVM?</span></span></p><p class="gmail-ng-star-inserted" style="box-sizing:border-box;font-size:14px;line-height:20px;margin-bottom:18px;font-family:"Google Sans Text","Helvetica Neue",sans-serif;color:rgb(26,28,30)"><span style="box-sizing:border-box;display:contents"><span class="gmail-ng-star-inserted" style="box-sizing:border-box">I also noticed that current versions of CRaC include File Descriptor Policies. These allow configuring an </span><span class="gmail-inline-code gmail-ng-star-inserted" style="box-sizing:border-box;background-image:none;background-position:0% 0%;background-size:auto;background-repeat:repeat;background-origin:padding-box;background-clip:border-box;border-color:rgb(243,243,246);border-style:solid;border-width:1px;border-radius:3px;font-size:13px;padding:0px 3px;display:inline-block;font-family:"DM Mono",monospace">action: ignore</span><span class="gmail-ng-star-inserted" style="box-sizing:border-box"> for specific file descriptors, effectively delegating their handling to CRIU. This seems to demonstrate that letting CRIU manage certain open files </span><span class="gmail-ng-star-inserted" style="box-sizing:border-box;font-style:italic">is</span><span class="gmail-ng-star-inserted" style="box-sizing:border-box"> feasible within the CRaC framework.</span></span></p><p class="gmail-ng-star-inserted" style="box-sizing:border-box;font-size:14px;line-height:20px;margin-bottom:18px;font-family:"Google Sans Text","Helvetica Neue",sans-serif;color:rgb(26,28,30)"><span style="box-sizing:border-box;display:contents"><span class="gmail-ng-star-inserted" style="box-sizing:border-box">This leads me to wonder: if delegation to CRIU is possible and works (at least for some cases via policies), why isn't relying on CRIU for resource handling the default or more broadly encouraged approach? Why the strict requirement for manual closure and reopening in the general case?</span></span></p><p class="gmail-ng-star-inserted" style="box-sizing:border-box;font-size:14px;line-height:20px;margin-bottom:18px;font-family:"Google Sans Text","Helvetica Neue",sans-serif;color:rgb(26,28,30)"><span style="box-sizing:border-box;display:contents"><span class="gmail-ng-star-inserted" style="box-sizing:border-box">For instance, consider using </span><span class="gmail-inline-code gmail-ng-star-inserted" style="box-sizing:border-box;background-image:none;background-position:0% 0%;background-size:auto;background-repeat:repeat;background-origin:padding-box;background-clip:border-box;border-color:rgb(243,243,246);border-style:solid;border-width:1px;border-radius:3px;font-size:13px;padding:0px 3px;display:inline-block;font-family:"DM Mono",monospace">System.getLogger()</span><span class="gmail-ng-star-inserted" style="box-sizing:border-box"> from the JDK Platform Logging API. As application developers, we don't typically manage the underlying file descriptor for the log file directly. To make this work with CRaC, we currently need to identify and configure a File Descriptor Policy for it, which can feel somewhat cumbersome. Wouldn't a smoother experience involve CRaC (perhaps optionally) defaulting to letting CRIU handle such internally managed resources, like those opened by standard JDK libraries?</span></span></p><p class="gmail-ng-star-inserted" style="box-sizing:border-box;font-size:14px;line-height:20px;margin-bottom:18px;font-family:"Google Sans Text","Helvetica Neue",sans-serif;color:rgb(26,28,30)"><span style="box-sizing:border-box;display:contents"><span class="gmail-ng-star-inserted" style="box-sizing:border-box">I would appreciate any insights or clarification you could offer on the design philosophy behind CRaC's approach to managing external resources like files and sockets, especially in contrast to CRIU's capabilities.</span></span></p><p class="gmail-ng-star-inserted" style="box-sizing:border-box;font-size:14px;line-height:20px;margin-bottom:18px;font-family:"Google Sans Text","Helvetica Neue",sans-serif;color:rgb(26,28,30)"><span style="box-sizing:border-box;display:contents"><span class="gmail-ng-star-inserted" style="box-sizing:border-box">Thanks for your time and any insights you can share.</span></span></p><p class="gmail-ng-star-inserted" style="box-sizing:border-box;font-size:14px;line-height:20px;margin-bottom:18px;font-family:"Google Sans Text","Helvetica Neue",sans-serif;color:rgb(26,28,30)"><span style="box-sizing:border-box;display:contents"><span class="gmail-ng-star-inserted" style="box-sizing:border-box">Best regards,</span></span></p><p class="gmail-ng-star-inserted" style="box-sizing:border-box;font-size:14px;line-height:20px;margin-bottom:0px;font-family:"Google Sans Text","Helvetica Neue",sans-serif;color:rgb(26,28,30)">mazhen</p></div></div></div>